<template>
  <div>
    <h1>register</h1>
    <!-- <el-button>注册</el-button> -->
    <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="用户名">
        <el-input v-model="form.user_name"></el-input>
      </el-form-item>
      <el-form-item label="密码">
        <el-input v-model="form.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSubmit">注册</el-button>
        <el-button>取消</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import ajax from "../ajax/ajax";
import { Form, FormItem, Input, Button } from "element-ui";
export default {
  name: "",
  props: [""],
  data() {
    return {
      form: {
        user_name: "",
        password: "",
      },
    };
  },

  components: {
    "el-form": Form,
    "el-form-item": FormItem,
    "el-input": Input,
    "el-button": Button,
  },

  computed: {},

  beforeMount() {},

  mounted() {},

  methods: {
    async onSubmit() {
      // 测试是否能收集到form表单中的数据
      console.log(this.form);
      // 将收集到的用户名和密码，提交给服务器
      const result = await ajax("post", "register", this.form, "form");
      console.log(result);
    },
  },

  watch: {},
};
</script>
<style lang='' scoped>
</style>